//
//  YLTitleHeader.m
//  YLFinanceService
//
//  Created by she1323 on 2017/8/25.
//  Copyright © 2017年 she1323. All rights reserved.
//

#import "YLTitleHeader.h"
#import <Masonry.h>
#import "YLGlobeHeader.h"
@interface YLTitleHeader ()
@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UIView *line;
@property (nonatomic, weak) UIImageView *icon;
@end

@implementation YLTitleHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setTitleColor:(UIColor *)titleColor
{
    _titleColor = titleColor;
    _titleLabel.textColor = titleColor;
}

- (void)setTitle:(NSString *)title
{
    _title = title;
    _titleLabel.text = title;
}

- (void)setUpUI
{
    
    __weak typeof(self) weakSelf = self;
    UILabel *titleLabel = [[UILabel alloc] init];
    _titleLabel = titleLabel;
    [self addSubview:titleLabel];
    titleLabel.text = @"基金详情";
    titleLabel.textAlignment = NSTextAlignmentLeft;
    titleLabel.font = [UIFont boldSystemFontOfSize:18.0f];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf).mas_offset(15);
        make.top.right.bottom.mas_equalTo(weakSelf);
    }];
    
    UIView *line = [[UIView alloc] init];
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.mas_equalTo(weakSelf);
        make.bottom.mas_equalTo(weakSelf);
        make.height.mas_equalTo(1);
    }];
    line.backgroundColor = YLLineColor;
    line.alpha = 0.4;
    line.hidden = YES;
    _line = line;
    
    UIImageView *icon = [[UIImageView alloc] init];
    [self addSubview:icon];
    [icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(weakSelf).mas_offset(-23);
        make.top.mas_equalTo(weakSelf).mas_offset(9);
        make.bottom.mas_equalTo(weakSelf).mas_offset(10);
        make.width.mas_equalTo(icon.mas_height);
    }];
    icon.image = [UIImage imageNamed:@"abandoned"];
    icon.hidden = YES;
    _icon = icon;
}

- (void)setShowCancelStatus:(BOOL)showCancelStatus
{
    _showCancelStatus = showCancelStatus;
    _icon.hidden = showCancelStatus;
    
}

- (void)setHiddenLine:(BOOL)hiddenLine
{
    _hiddenLine = hiddenLine;
    _line.hidden = hiddenLine;
}

@end
